package model

type BookBuilder struct {
	id       int     //必须
	bookName string  //必须
	price    float64 //非必须
}

func NewBookBuilder(id int, name string) *BookBuilder {
	return &BookBuilder{id: id, bookName: name}
}

func (this *BookBuilder) SetPrice(price float64) *BookBuilder {

	this.price = price
	return this
}

func (this *BookBuilder) Build() *Book {
	book := &Book{}

	book.Id = this.id
	book.BookName = this.bookName
	if this.price > 0 {
		book.Price = this.price
	}
	return book
}
